window.onload = function(){
    var content =  document.getElementById("content");
    var areas =  document.getElementById("areas");
    var drop =  document.getElementById("drop");
    var fork =  document.getElementById("fork");
    var city =  document.getElementById("city");
    var main = document.getElementById("main");
    var name = document.getElementById("name");
    var btn= document.getElementById("btn");
    var inputs = main.getElementsByTagName("input");
    var defaults =  document.getElementById("defaults");
    var items = document.getElementsByClassName("item");
    // console.log(btn);
   drop.onclick = function () {
      areas.style.display = "block";
   }
    fork.onclick = function () {
        areas.style.display = "none";
    }
    for(var i = 0;i<items.length;i++){
       items[i].suoYin = i;
       items[i].onclick = function () {
           city.value = items[this.suoYin].innerHTML;
           areas.style.display = "none";
       }
    }
    var s = 0;
    defaults.onclick = function () {
        s++;
       if(s%2==1){
           defaults.style.background = "#4EC02C";
       }else{
           defaults.style.background = "";
       }

    }
    for(var j = 0;j<inputs.length;j++) {
        items[j].suoYin = j;
        inputs[j].onfocus = function () {
            this.value = "";
        }
    }
    btn.onclick = function () {
        name = name.value;
        if(name==""){
            alert("姓名不能为空");
        }
        for(var d = 0;d<name.length;d++){
            var zifu = name.charAt(d);
            if(zifu>=0){
                alert("姓名中不能有数字");
                break;
            }
        }
    }

}